<template>
  <div class="contaier">
    <van-nav-bar left-text="返回" left-arrow @click-left="back" />
    <van-field v-model="ban" label="板块" placeholder="请输入板块名称" />
    <van-field v-model="name" label="名字" placeholder="请输入主题名" />
    <van-field v-model="desc" label="描述" placeholder="请输入描述信息" />
    <van-field
      v-model="content"
      rows="2"
      autosize
      label="内容"
      type="textarea"
      maxlength="50"
      placeholder="请输入内容"
      show-word-limit
    />
    <van-button
      type="primary"
      style="width: 94%; margin-left: 3%"
      plain
      size="small"
      @click="submit()"
      >发布</van-button
    >
  </div>
</template>

<script>
import { fabuTie } from "../services/luntan";
import { Toast } from "vant";
export default {
  data() {
    return {
      ban: this.$route.params.name,
      name: "",
      desc: "",
      content: "",
    };
  },
  methods: {
    back() {
      window.history.go(-1);
    },
    async submit() {
      const res = await fabuTie(
        this.$route.params.id,
        this.name,
        this.desc,
        this.content
      );
      Toast.success(res.msg);
      console.log(res);
    },
  },
};
</script>

<style>
</style>